package net.lab1024.sa.admin.module.business.contact.controller;

import net.lab1024.sa.admin.module.business.contact.domain.form.ContactAddForm;
import net.lab1024.sa.admin.module.business.contact.domain.form.ContactQueryForm;
import net.lab1024.sa.admin.module.business.contact.domain.form.ContactUpdateForm;
import net.lab1024.sa.admin.module.business.contact.domain.vo.ContactVO;
import net.lab1024.sa.admin.module.business.contact.service.ContactService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 联系方式 Controller
 *
 * @Author 1
 * @Date 2025-06-20 16:36:02
 * @Copyright 1
 */

@RestController
@Tag(name = "联系方式")
public class ContactController {

    @Resource
    private ContactService contactService;

    @NoNeedLogin
    @Operation(summary = "分页查询 @author 1")
    @PostMapping("/contact/queryPage")
//    @SaCheckPermission("contact:query")
    public ResponseDTO<PageResult<ContactVO>> queryPage(@RequestBody @Valid ContactQueryForm queryForm) {
        return ResponseDTO.ok(contactService.queryPage(queryForm));
    }

    @NoNeedLogin
    @Operation(summary = "添加 @author 1")
    @PostMapping("/contact/add")
//    @SaCheckPermission("contact:add")
    public ResponseDTO<String> add(@RequestBody @Valid ContactAddForm addForm) {
        return contactService.add(addForm);
    }

    @NoNeedLogin
    @Operation(summary = "更新 @author 1")
    @PostMapping("/contact/update")
//    @SaCheckPermission("contact:update")
    public ResponseDTO<String> update(@RequestBody @Valid ContactUpdateForm updateForm) {
        return contactService.update(updateForm);
    }

    @NoNeedLogin
    @Operation(summary = "批量删除 @author 1")
    @PostMapping("/contact/batchDelete")
//    @SaCheckPermission("contact:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return contactService.batchDelete(idList);
    }

    @NoNeedLogin
    @Operation(summary = "单个删除 @author 1")
    @GetMapping("/contact/delete/{id}")
//    @SaCheckPermission("contact:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return contactService.delete(id);
    }
}
